﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:local="clr-namespace:Charts"
	xmlns:conv="clr-namespace:Charts.Converters"
>
	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="..\Resources\Theme.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	
	<Style TargetType="local:ValueAxis">
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ItemsControl">
					<ItemsPresenter/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		
		<Setter Property="ItemsControl.ItemsPanel">
			<Setter.Value>
				<ItemsPanelTemplate>
					<Canvas IsItemsHost="True"/>
				</ItemsPanelTemplate>
			</Setter.Value>
		</Setter>
		
		<Setter Property="ItemsControl.ItemContainerStyle">
			<Setter.Value>
				<Style TargetType="ContentPresenter">
					
					<Setter Property="Canvas.Top">
						<Setter.Value>
							<MultiBinding Converter="{conv:YValueAxisConverter}">
								<Binding RelativeSource="{RelativeSource Self}"/>
								<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"
								         Path="ActualHeight"/>
								<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"
								         Path="ItemsSource"/>
							</MultiBinding>
						</Setter.Value>
					</Setter>
					
					<Setter Property="Canvas.Left">
						<Setter.Value>
							<Binding RelativeSource="{RelativeSource Self}"
							         Path="ActualWidth"
							         ConverterParameter="{StaticResource valueAxisLabelShift}"
							         Converter="{conv:DoubleInverseConverter}"/>
						</Setter.Value>
					</Setter>
				
				</Style>
			</Setter.Value>
		</Setter>
		
		<Setter Property="ItemsSource">
			<Setter.Value>
				<MultiBinding Converter="{conv:YValueAxisItemsConverter}">
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Minimum"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Maximum"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Count"/>
				</MultiBinding>
			</Setter.Value>
		</Setter>
	
	</Style>

</ResourceDictionary>